package com.topcycle.tlight;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;


/**
 * Created by Administrator on 15-7-14.
 */
public class SplashActivity extends MainActivity{

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        DeviceManager.readFromLocal(SplashActivity.this);
        NetController.init(SplashActivity.this);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
                SplashActivity.this.startActivity(mainIntent);
                SplashActivity.this.finish();
            }
        }, 1000);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private boolean isRunningForegrund (Context context) {
        ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
        ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
        String currentPackagename = cn.getPackageName();
        if (!TextUtils.isEmpty(currentPackagename) && currentPackagename.equals(getPackageName())) {
            return true;
        }
        return false;
    }

}
